package com.shao.array;

public class array04 {
    public static void main(String[] args) {

        int[] nums={1,2,5,4,8,9};
        for (int i : nums) {
//            前面是数组中的每一个元素，后面是数组,娶不到下标|
            System.out.println(i);
        }
        System.out.println("===========================");
        printa(nums);
        System.out.println("===========================");
//        反转数组，先定义一个数组令其翻转，然后在输出那个数组，然后
        int[] recerse=reverse(nums);

        System.out.println("===========================");

        printa(recerse);
//        System.out.println(reverse(nums));

    }
//    打印数组
    public static void printa(int [] printar){
        for (int i = 0; i < printar.length; i++) {
            System.out.println(printar[i]);
        }

    }

//翻转数组
public static int[] reverse(int[] arrays){
        int[] num=new int[arrays.length];
//        翻转操作
    for (int i=0, j = arrays.length-1; i <arrays.length ; i++,j--) {
     num[j]=arrays[i];

    }
    return num;
}

}
